package com.zhiyun.service.impl;

import com.zhiyun.domain.Student;
import com.zhiyun.mapper.StudentMapper;
import com.zhiyun.service.StudentService;
import com.zhiyun.util.Db;
import com.zhiyun.vo.Result;

import java.util.List;

/**
 * @author zc
 * @Date 2025/4/29 上午9:24
 */
public class StudentServiceImpl implements StudentService {
    StudentMapper studentMapper = Db.getMapper(StudentMapper.class);
    @Override
    public Result myInfo(int studentId) {
        return Result.ok(studentMapper.selectByPrimaryKey(studentId));
    }

    @Override
    public Result updateStudent(Student student) {
        int rows = studentMapper.updateByPrimaryKey(student);
        if (rows > 0) {
            return Result.okMsg("修改成功");
        }else {
            return Result.fail("修改失败");
        }
    }

    @Override
    public Result AllStudent() {
        List<Student> list = studentMapper.findAll();
        return Result.ok(list);
    }
}
